package com.suxin.socket.yinfei.pusher;

import com.alibaba.fastjson.JSON;
import com.suxin.socket.yinfei.AbstractWebSocketConnection;
import com.suxin.socket.yinfei.session.SessionConnectionHolder;

/**
 * @author Tang
 * @classname DefaultPusherHandler
 * @description [  ]
 * @date 2021/8/19 21:31
 */
public class DefaultPusherHandler extends AbstractPusherHandler<Object> {

    public DefaultPusherHandler(SessionConnectionHolder sessionConnectionHolder) {
        super(sessionConnectionHolder);
    }

    @Override
    public void push(Object msg, String identifier) {
        sessionConnectionHolder.getSession(identifier).forEach(session -> {
            AbstractWebSocketConnection.sendMsg(JSON.toJSONString(msg),session);
        });
    }
}